﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Web;

namespace TWS.Cart.Business
{
    /// <summary>
    /// Summary description for CookieManager
    /// </summary>
    public class CookieManager
    {
	    public CookieManager()
	    {		
	    }

        //cookies:
        //1) for user

        public HttpCookie CookieUser 
        { 
            get
            {
                if (HttpContext.Current.Request.Cookies["TWSCartUser"] != null)
                    return HttpContext.Current.Request.Cookies["TWSCartUser"];
                else
                {
                    HttpCookie c = new HttpCookie("TWSCartUser");
                    c.Expires = DateTime.Now.AddYears(5);
                    return c;
                }
            }
            set
            {
                HttpCookie c = value;
                //Each time we set a value we update the cookies expiration date.
                c.Expires = DateTime.Now.AddYears(5);

                //Add to cookie space.
                HttpContext.Current.Response.Cookies.Add(c);                
            }
        }


        public void AddUser(string UserName, string UserEmail)
        {
            CookieUser.Values.Add("UserName",UserName);
            CookieUser.Values.Add("UserEmail", UserEmail);            
        }        
    }
}
